package com.example.test.util;

import com.sun.xml.internal.bind.v2.model.core.EnumConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;
import java.util.Enumeration;
import java.util.Properties;

public class ApiUtil {
             private static Logger logger= LoggerFactory.getLogger(ApiUtil.class);

    public static void main(String[] args) throws IOException {
        Properties properties=new Properties();
        InputStream is=ApiUtil.class.getClassLoader().getResourceAsStream("application.properties");
        properties.load(is);
        OutputStream os=new BufferedOutputStream(new FileOutputStream("test.properties"));
        properties.store(os,"hello");
        //获取文件中的所有key
        Enumeration enumeration=properties.propertyNames();//得到配置文件的名稱
        //遍历key
        while (enumeration.hasMoreElements()){
            String key= (String) enumeration.nextElement();
            //根据对应key获取相应的value
            String value=properties.getProperty(key);
            logger.info("key:"+key+",value:"+value);
        }
        System.out.println(enumeration);
        properties.list(System.out);
//        System.out.println("name:"+properties.getProperty("name"));
//        logger.info("成功了");
//        System.out.println("配置参数:"+properties);
    }
}
